#ifndef CAPILOT_DATA_RECEIVER_H
#define CAPILOT_DATA_RECEIVER_H

#include "raw_message.h"
#include "public_define.h"

//#include "ca/log/log.h"
#include "ca_node.h"
// #include "ca/protocol/publisher.h"
// #include "ca/protocol/subscriber.h"
#include <functional>

class adr_component;

class CapilotDataReceiver
{
public:
    CapilotDataReceiver();
    ~CapilotDataReceiver();
    void init(adr_component *handle, const std::string &topic, std::function<void(const std::string &, const capilot::RawMessage &, const double &)> func);
    //void init(adr_component *handle, const std::string &topic, std::function<void(const std::string &, const capilot::RawMessage &, const double &)> func);
    //void init(std::shared_ptr<ca::basic::cm::AsyncSubscriber> sub, const std::string &topic, std::function<int(const std::string &topic,const ca::basic::core::RawBuffer *data, const ca::basic::core::RawBuffer *header)> func);
    void initRpc(adr_component *handle, const std::string &topic, std::function<void(const std::string &, const std::string &, std::string *)> func);
    void onObjectCallback(const capilot::RawMessage &data, double time);
    //void onObjectCallback(const std::string &data, double time);
    //int onObjectCallback(const std::string &topic, const ca::basic::core::RawBuffer *data, const ca::basic::core::RawBuffer *header);
    void onObjectRpcCallback(const std::string &requestData, std::string *replyData);

private:
    std::string m_topic{""};
    std::string m_topic_rpc{""};
    //std::function<void(const std::string &, const std::string &, const double &)> m_callBack;
    std::function<void(const std::string &, const capilot::RawMessage &, const double &)> m_callBack;
    //std::function<int(const std::string &topic,const ca::basic::core::RawBuffer *data, const ca::basic::core::RawBuffer *header)> m_callBack;
    std::function<void(const std::string &, const std::string &, std::string *)> m_callBack_Rpc;
};

#endif // CAPILOT_DATA_RECEIVER_H